package com.lhsy.djcloud.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lhsy.djcloud.entity.User;
import com.lhsy.djcloud.entity.dto.AccountDto;
import com.lhsy.djcloud.mapper.UserMapper;
import com.lhsy.djcloud.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangzw
 * @since 2020-09-16
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired UserMapper userMapper;
    @Override
    public User selectByUserName(String loginName) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        User user = new User();
        user.setUsername(loginName);
        queryWrapper.setEntity(user);
        return getOne(queryWrapper);
    }

    @Override
    public void deleteByDept(Integer deptId) {

        userMapper.deleteByDept(deptId);
    }

    @Override
    public List<User> getNoSelfList(Integer userId,Integer tenantId) {

        return userMapper.getNoSelfList(userId,tenantId);
    }

    @Override
    public User selectByDept(Integer deptId) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        User user = new User();
        user.setDeptId(deptId);
        queryWrapper.setEntity(user);
        return getOne(queryWrapper);
    }

    @Override
    public List<User> selectByDeptIds(List<Integer> deptids) {
        return userMapper.selectByDeptIds(deptids);
    }

    @Override
    public List<AccountDto> selectAccountList(String userName, Integer level ,Integer tenantId) {

        return userMapper.selectAccountList(userName,level,tenantId);
    }
}
